/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.oracleandsxnd.erp.member.web;

import com.oracleandsxnd.erp.common.persistence.Page;
import com.oracleandsxnd.erp.common.persistence.TableSplitResult;
import com.oracleandsxnd.erp.common.web.AjaxResult;
import com.oracleandsxnd.erp.common.web.BaseController;
import com.oracleandsxnd.erp.member.entity.MemberCategory;
import com.oracleandsxnd.erp.member.service.MemberCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 会员类别Controller
 * @author 会员类别
 * @version 2019-12-13
 */
@Controller
@RequestMapping(value = "member_memberCategory")
public class MemberCategoryController extends BaseController {

	@Autowired
	private MemberCategoryService memberCategoryService;

	@RequestMapping(value = {""})
	public String list(MemberCategory memberCategory, HttpServletRequest request, HttpServletResponse response, Model model) {
		return "erp/member/memberCategoryList";
	}

	@RequestMapping(value = {"listData"})
	@ResponseBody
	public Object listData(MemberCategory memberCategory , HttpServletRequest request, HttpServletResponse response){
		Page<MemberCategory> page = memberCategoryService.findPage(new Page<MemberCategory>(request, response), memberCategory);
		TableSplitResult<MemberCategory> result=new TableSplitResult<MemberCategory>(page.getPageNo(), page.getCount(), page.getList());
		return  result;
	}
	@RequestMapping(value = "save")
	@ResponseBody
	public AjaxResult save(MemberCategory memberCategory) {

		memberCategoryService.save(memberCategory);
		 return success();
	}
	
	@RequestMapping(value = "delete")
	@ResponseBody
	public AjaxResult  delete(MemberCategory memberCategory, RedirectAttributes redirectAttributes) {
		memberCategoryService.delete(memberCategory);
		return success();
	}

}